import VueRouter from 'vue-router'

//处理跳转同一个路由(点击同一个菜单)报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
export default new VueRouter({
    routes: [{
            path: "/",
            redirect: "/home"
        }, {
            path: '/login',
            name: 'login',
            component: () => import('@/views/Login.vue')
        }, {
            path: '/register',
            name: 'register',
            component: () => import('@/views/Register.vue')

        },
        {
            path: '/myContainer',
            name: 'myContainer',
            component: () => import('@/views/MyContainer.vue'),
            children: [{
                    path: '/home',
                    name: 'home',
                    component: () => import('@/views/Home.vue')
                },
                {
                    path: '/dashBoard',
                    name: 'dashBoard',
                    component: () => import('@/views/DashBoard.vue')
                },
                {
                    path: '/bookList',
                    name: 'bookList',
                    component: () => import('@/views/BookList.vue')
                },
                {
                    path: '/bookDetail/:isbn',
                    name: 'bookDetail',
                    component: () => import('@/views/BookDetail.vue')
                },
                {
                    path: '/borrowInfo/:type',
                    name: 'borrowInfo',
                    component: () => import('@/views/BorrowInfo.vue')
                }
            ]
        }
    ]
})